package memento.white_box;

/**
 * @Author: Doream
 * @Date: 2022/1/30 14:46
 */
// 游戏角色类(属于发起人角色)
public class GameRole {
    private int hp;  // 生命值
    private int atk; // 攻击力
    private int def; // 防御力

    // 初始化方法
    public void initState() {
        this.hp = 100;
        this.atk = 50;
        this.def = 30;
    }

    // 战斗方法
    public void fight() {
        this.hp = 20;
        this.atk = 10;
        this.def = 10;
    }

    // 保存状态
    public RoleStateMemento saveState() {
        return new RoleStateMemento(this.hp, this.atk, this.def);
    }

    // 恢复角色状态
    public void recoverState(RoleStateMemento roleStateMemento){
        this.hp = roleStateMemento.getHp();
        this.atk = roleStateMemento.getAtk();
        this.def = roleStateMemento.getDef();
    }

    // 展示状态功能
    public void stateDisplay(){
        System.out.println("角色生命力："+this.hp);
        System.out.println("角色攻击力："+this.atk);
        System.out.println("角色防御力："+this.def);
    }

    public int getHp() {
        return hp;
    }

    public void setHp(int hp) {
        this.hp = hp;
    }

    public int getAtk() {
        return atk;
    }

    public void setAtk(int atk) {
        this.atk = atk;
    }

    public int getDef() {
        return def;
    }

    public void setDef(int def) {
        this.def = def;
    }


}
